<?php

namespace App\Model\Foundation;


use Illuminate\Database\Eloquent\Model;

class CourseType extends Model
{
    public $table = 'coursetypes';
    public $primaryKey = 'coursetypeuid';

    protected $fillable = [
        'coursetypename',
        'colorvalue',
        'remark'
    ];

    static function getCourseTypes($ids, $field=false)
    {
        $items = static::find($ids);
        if(!$field){
            return $items;
        }else{
            $values = [];
            foreach ($items as $item){
                $values[] = $item->$field;
            }
        }
        return $values;
    }

    static function getCourseTypeId($name){
        $courseId = static::where('coursetypename',$name)->value('coursetypeuid');
        return courseId;

    }

}
